package com.h2cloud.sort;

/**
 * @Package: com.h2cloud.sort
 * @ClassName: bubbleSort
 * @Author: h2cloud
 * @CreateTime: 2021/4/15 10:18 下午
 * @Description:
 */
public class _1_bubbleSort {
    public static void main(String[] args) {

        int[] ints = myArray.get(10000);
        long startTime = System.currentTimeMillis();
        bubbleSort(ints);
        System.out.println("时间：" + (System.currentTimeMillis() - startTime + "ms"));
    }

    static void bubbleSort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j + 1]) {//交换值
                    arr[j] = arr[j] ^ arr[j + 1];
                    arr[j + 1] = arr[j] ^ arr[j + 1];
                    arr[j] = arr[j] ^ arr[j + 1];
                }
            }
        }
    }
}
